package com.freemalll.merchant.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.freemalll.common.core.annotation.ResultInterceptor;
import com.freemalll.merchant.domain.dto.SysConfigDto;
import com.freemalll.merchant.domain.entity.common.SysConfig;
import com.freemalll.merchant.service.SysConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "系统配置：配置信息")
@RestController
@RequestMapping("/system-config")
@RequiredArgsConstructor
@ResultInterceptor
public class SysConfigController {

    private final SysConfigService sysCfgManager;


    @Operation(summary = "刷新缓存")
    @PostMapping("/refresh")
    public boolean refreshConfigCache() {
        return sysCfgManager.refreshConfigCache();
    }

    @Operation(summary = "分页")
    @PostMapping("page")
    public Page<SysConfig> pageSearch(@RequestBody SysConfigDto dto) {
        return sysCfgManager.pageSearch(dto);
    }


    @Operation(summary = "编辑")
    @PostMapping("/editConfig")
    public boolean editConfig(@RequestBody SysConfigDto dto) {
        return sysCfgManager.editConfig(dto);
    }


}
